<template>
  <view class="BCPage">
    <image src="../../static/my/bmdz.png" class="bg" mode="aspectFill" />
    <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
      <!-- <view class="chatBox"> -->
      <view class="title">变美定制<view class="line"></view></view>
      <view class="contentBox">
        <view v-for="(item, j) in msgList">
          <view :class="[item.type == '1' ? 'meMsgLine' : 'yourMsgLine']">
            <view :class="[item.type == '1' ? 'meMsgBox' : 'yourMsgBox', 'msgBox']">
              <view class="imgBox"></view>
              <view :class="[item.type == '1' ? 'meChat' : 'yourChat', 'contentChat']">{{ item.content }}</view>
            </view>
          </view>
        </view>
      </view>
      <!-- </view> -->
    </scroll-view>
    <view class="inputBox1" @click="showComments()">
      <view class="ip">想要说点什么</view>
    </view>
    <u-popup :show="show" mode="bottom" @close="close" @open="open" v-if="show">
      <view class="plInputBox">
        <view class="input" :style="{ width: plInfo ? '100%' : '80%' }">
          <u-textarea
            :height="60"
            :cursorSpacing="100"
            :focus="focus"
            border="none"
            :showConfirmBar="false"
            v-model="plInfo"
            placeholder="快发表你的评论吧"
            count
            autoHeight
            maxlength="300"
          ></u-textarea>
        </view>
        <view class="btnBox">
          <u-button type="primary" v-if="plInfo" size="small" @click="postComments">发布</u-button>
        </view>
      </view>
    </u-popup>
  </view>
</template>
<script setup lang="ts">
import { nextTick, onMounted, ref } from "vue";
const scrollTop = ref(0);
const msgList = ref<any>([
  {
    headUrl: "123123123",
    content: "Content 祝我们在乱七八糟的生活里都能够找到快乐！",
    type: "1", //自己
  },
]);
const show = ref(false);
const focus = ref(false);
const plInfo = ref("");

const showComments = () => {
  show.value = true;
  focus.value = true;
};
const open = () => {
  show.value = true;
  console.log("open");
};
const close = () => {
  show.value = false;
  console.log("close");
};
const blur = () => {
  focus.value = false;
};
const postComments = async () => {
  msgList.value.push({
    headUrl: "123123123",
    content: plInfo.value,
    type: "1", //自己
  });
  plInfo.value = "";
  nextTick(() => {
    scrollTop.value += 100;
  });

  close();
};
</script>
<style lang="less" scoped>
.BCPage {
  // #ifdef APP-PLUS
  max-height: 100vh;
  // #endif
  // #ifdef H5
  max-height: 94vh;
  // #endif

  position: relative;
  .bg {
    width: 100%;
    margin-top: -80rpx;
    height: 562rpx;
    position: relative;
    z-index: 1;
  }
  .scroll-Y {
    box-sizing: border-box;
    position: relative;
    z-index: 99;
    height: calc(100vh - 642rpx);
    position: relative;
    z-index: 99;
    background: #f3f4f6;
    border-radius: 32rpx 32rpx 0rpx 0rpx;
    padding: 32rpx;
    margin-top: -53rpx;
    overflow: auto;
    padding-bottom: 0rpx;
    .title {
      height: 44rpx;
      font-family: DingTalk JinBuTi, DingTalk JinBuTi;
      font-weight: bold;
      font-size: 36rpx;
      color: #333333;
      line-height: 44rpx;
      position: fixed;
      width: 86%;
      background: #f3f4f6;
      padding: 20rpx;
      margin-top: -20rpx;

      .line {
        position: absolute;
        bottom: 20rpx;
        width: 135rpx;
        height: 14rpx;
        background: #81d8d0;
        border-radius: 0rpx 0rpx 0rpx 0rpx;
        opacity: 0.3;
      }
    }
    .contentBox {
      display: flex;
      flex-flow: column;
      padding-top: 80rpx;
      .dateText {
        font-family: DINPro, DINPro;
        font-weight: 300;
        font-size: 26rpx;
        color: #8a8a8d;
        line-height: 110rpx;
        text-align: center;
      }
      .imgBox {
        width: 80rpx;
        height: 80rpx;
        border-radius: 50%;
        border: 1rpx solid gainsboro;
      }
      .msgBox {
        width: 95%;
        display: flex;
        flex-flow: row;
        flex-wrap: nowrap;
        gap: 16rpx;
      }

      .meMsgLine {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 52rpx;
        .meMsgBox {
          flex-direction: row-reverse;

          .meChat {
            background: #81d8d0;
          }
        }
      }
      .yourMsgLine {
        display: flex;
        justify-content: flex-start;
        margin-bottom: 52rpx;

        .yourMsgBox {
          .yourChat {
            background: #fff;
            color: #000;
          }
        }
      }
      .contentChat {
        width: calc(100% - 140rpx);
        border-radius: 32rpx;
        padding: 24rpx;
        flex-wrap: wrap;
        word-wrap: break-word;
      }
    }
  }
}
.inputBox1 {
  display: flex;
  justify-content: space-between;
  width: 100vw;
  position: absolute;
  left: 0rpx;
  // #ifdef APP-PLUS
  bottom: 10rpx;
  // #endif
  // #ifdef H5
  bottom: -110rpx;
  // #endif

  z-index: 9999;
  .ip {
    width: 95%;
    padding: 20rpx 40rpx;
    background: #fff;
    border-radius: 200rpx 200rpx 200rpx 200rpx;
    font-size: 28rpx;
    color: #8a8a8d;
  }
}
.plInputBox {
  padding: 10rpx 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .btnBox {
    width: 16%;
    margin-left: 10rpx;
  }
}
</style>
